#ifndef ACAPELLA_SYNCHRONIZE_MUTEX_COND_WINDOWS_EVENT_HPP
#define ACAPELLA_SYNCHRONIZE_MUTEX_COND_WINDOWS_EVENT_HPP

#include <windows.h>

namespace acapella
{
namespace synchronize
{

class mutex_cond
{
public:
	mutex_cond()
	{
		event_ = CreateEvent(NULL, FALSE, FALSE, NULL);
	}

	~mutex_cond()
	{
		CloseHandle(event_);
	}

	int wait()
	{
		WaitForSingleObject(event_, INFINITE);
		return 0;
	}

	int wait(_uint32_ timeout)
	{
		WaitForSingleObject(event_, timeout);
		return 0;
	}

	int signal()
	{
		SetEvent(event_);
		return 0;
	}

	int boardcast()
	{
		PulseEvent(event_);
		return 0;
	}

private:
	HANDLE event_;

	mutex_cond(const mutex_cond&);
	mutex_cond& operator=(const mutex_cond&);
};


}
}


#endif

